package com.standardoperationapp.adapter;

import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.standardoperationapp.R;
import com.standardoperationapp.bean.CardPointBean;
import com.standardoperationapp.bean.CardPointStepBean;

import java.util.List;

public class CardPointStepAdapter extends BaseAdapter {
    private List<CardPointStepBean.DataBean> list;
    private LayoutInflater mInflater;

    public CardPointStepAdapter(Context context, List<CardPointStepBean.DataBean> list1) {
        list = list1;
        mInflater = LayoutInflater.from(context);
    }



    public int getCount() {
        return list.size();
    }

    public Object getItem(int position) {
        return list.get(position);
    }

    public long getItemId(int position) {
        return position;
    }

    public int getItemViewType(int position) {
        return position;
    }

    public View getView(int position, View convertView, ViewGroup parent)
    {
        CardPointStepBean.DataBean item = list.get(position);
        ViewHolder viewHolder = null;

        if(convertView == null){
            convertView = mInflater.inflate(R.layout.item_card_point, null);
            viewHolder= new ViewHolder(convertView);
            convertView.setTag(viewHolder);
        }
        else{
            viewHolder = (ViewHolder)convertView.getTag();
        }

        viewHolder.tvName.setText(item.getMethodName());

        if (item.getOperateStatus().equals("1")) {
            viewHolder.llContent.setBackgroundColor(Color.GREEN);
        }

        return convertView;
    }
    class ViewHolder {
        protected TextView tvName;
        protected LinearLayout llContent;

        public ViewHolder(View convertView){
            this.tvName =  convertView.findViewById(R.id.tv_name);
            this.llContent =  convertView.findViewById(R.id.ll_content);
        }
    }
}
